home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
moonstonemadness.swf
/
scripts
/
__Packages
/
Library
/
Sound
/
SoundManager.as
< prev
Wrap
Text File
|
2007-09-27
|
9KB
|
267 lines
class Library.Sound.SoundManager
{
static var EVENT_SOUND_COMPLETE = 1;
static var DEFAULT_CATEGORY = "SFX";
static var MAX_SOUNDS_PLAYING = 8;
static var bInited = false;
function SoundManager()
{
}
static function doPlaySound(__sLinkage, __nVolume, __nLoop, __bUnique)
{
return Library.Sound.SoundManager.doPlaySoundInCat(Library.Sound.SoundManager.DEFAULT_CATEGORY,__sLinkage,__nVolume,__nLoop,__bUnique);
}
static function doPlaySoundInCat(__sCategoryName, __sLinkage, __nVolume, __nLoop, __bUnique)
{
Library.Sound.SoundManager.doCheckInit();
var _loc1_ = undefined;
if(Library.Sound.SoundManager.__get__NewSoundAllowed())
{
if(__nVolume == undefined)
{
__nVolume = 100;
}
if(__nLoop == undefined)
{
__nLoop = 1;
}
if(__bUnique == undefined)
{
__bUnique = false;
}
var _loc2_ = undefined;
if(__bUnique)
{
var _loc4_ = Library.Sound.SoundManager.isSoundPlaying(__sLinkage);
if(_loc4_.bPlaying)
{
_loc2_ = false;
_loc1_ = _loc4_.oSound;
}
else
{
_loc2_ = true;
}
}
else
{
_loc2_ = true;
}
if(_loc2_)
{
Library.Sound.SoundManager.doManageCategory(__sCategoryName);
var _loc5_ = Library.Sound.SoundManager.getMCForSound();
var _loc3_ = new Sound(_loc5_);
_loc3_.attachSound(__sLinkage);
if(_loc3_.duration != undefined)
{
_loc1_ = new Library.Sound.SoundItem(_loc3_,__sLinkage,__nVolume,__nLoop,__sCategoryName,_loc5_);
}
_loc1_.doAddListener(Library.Sound.SoundManager);
Library.Sound.SoundManager.aSounds.push(_loc1_);
}
}
return _loc1_;
}
static function isSoundPlaying(__sLinkageName)
{
var _loc1_ = new Object();
_loc1_.bPlaying = false;
_loc1_.oSound = undefined;
for(var _loc3_ in Library.Sound.SoundManager.aSounds)
{
if(Library.Sound.SoundManager.aSounds[_loc3_].LinkageName == __sLinkageName)
{
_loc1_.oSound = Library.Sound.SoundManager.aSounds[_loc3_];
_loc1_.bPlaying = true;
}
}
return _loc1_;
}
static function doManageExternalSound(__oSound)
{
Library.Sound.SoundManager.doCheckInit();
Library.Sound.SoundManager.doManageCategory(__oSound.__get__Category());
__oSound.doAddListener(Library.Sound.SoundManager);
Library.Sound.SoundManager.aSounds.push(__oSound);
}
static function getMCForSound()
{
var _loc1_ = Library.Sound.SoundManager.getNextDepth();
var _loc2_ = Library.Sound.SoundManager.mcAttach.createEmptyMovieClip("Snd" + _loc1_,_loc1_);
return _loc2_;
}
static function getNextDepth()
{
Library.Sound.SoundManager.nSoundNum = Library.Sound.SoundManager.nSoundNum + 1;
return Library.Sound.SoundManager.nSoundNum;
}
static function get SoundsQty()
{
return Library.Sound.SoundManager.aSounds.length;
}
static function doInit(__mcAttach)
{
Library.Sound.SoundManager.mcAttach = __mcAttach;
if(!Library.Sound.SoundManager.bInited)
{
Library.Sound.SoundManager.bInited = true;
Library.Sound.SoundManager.nSoundNum = 0;
Library.Sound.SoundManager.aSounds = new Array();
Library.Sound.SoundManager.aSoundCategories = new Array();
Library.Sound.SoundManager.nMasterVolume = 100;
_global.mx.transitions.OnEnterFrameBeacon.init();
Library.Sound.SoundManager.oEnterFrameListener = new Object();
Library.Sound.SoundManager.oEnterFrameListener.onEnterFrame = Library.Utils.Delegate.create(Library.Sound.SoundManager,Library.Sound.SoundManager.doEnterFrame);
MovieClip.addListener(Library.Sound.SoundManager.oEnterFrameListener);
}
}
static function doEnterFrame()
{
for(var _loc1_ in Library.Sound.SoundManager.aSounds)
{
Library.Sound.SoundManager.aSounds[_loc1_].doEnterFrame();
}
}
static function setCategoryVolume(__sCategoryName, __nVol)
{
Library.Sound.SoundManager.doManageCategory(__sCategoryName);
for(var _loc3_ in Library.Sound.SoundManager.aSoundCategories)
{
if(Library.Sound.SoundManager.aSoundCategories[_loc3_].sName == __sCategoryName)
{
Library.Sound.SoundManager.aSoundCategories[_loc3_].nVolume = __nVol;
}
}
Library.Sound.SoundManager.doUpdateAllSoundsVolume();
}
static function getCategoryVolume(__sCategoryName)
{
Library.Sound.SoundManager.doManageCategory(__sCategoryName);
var _loc1_ = undefined;
for(var _loc3_ in Library.Sound.SoundManager.aSoundCategories)
{
if(Library.Sound.SoundManager.aSoundCategories[_loc3_].sName == __sCategoryName)
{
_loc1_ = Library.Sound.SoundManager.aSoundCategories[_loc3_].nVolume;
}
}
return _loc1_;
}
static function isCategoryMuted(__sCategoryName)
{
Library.Sound.SoundManager.doManageCategory(__sCategoryName);
var _loc1_ = undefined;
for(var _loc3_ in Library.Sound.SoundManager.aSoundCategories)
{
if(Library.Sound.SoundManager.aSoundCategories[_loc3_].sName == __sCategoryName)
{
_loc1_ = Library.Sound.SoundManager.aSoundCategories[_loc3_].bMuted;
}
}
return _loc1_;
}
static function doSoundEvent(__nEvent, __oSound)
{
if(__nEvent === Library.Sound.SoundManager.EVENT_SOUND_COMPLETE)
{
var _loc1_ = false;
for(var _loc3_ in Library.Sound.SoundManager.aSounds)
{
if(!_loc1_)
{
if(Library.Sound.SoundManager.aSounds[_loc3_] == __oSound)
{
_loc1_ = true;
delete Library.Sound.SoundManager.aSounds[_loc3_];
Library.Sound.SoundManager.aSounds.splice(Number(_loc3_),1);
}
}
}
}
}
static function doMuteCategory(__sCategoryName)
{
for(var _loc2_ in Library.Sound.SoundManager.aSoundCategories)
{
if(Library.Sound.SoundManager.aSoundCategories[_loc2_].sName == __sCategoryName)
{
Library.Sound.SoundManager.aSoundCategories[_loc2_].bMuted = true;
}
}
Library.Sound.SoundManager.doUpdateAllSoundsVolume();
}
static function doUnMuteCategory(__sCategoryName)
{
for(var _loc2_ in Library.Sound.SoundManager.aSoundCategories)
{
if(Library.Sound.SoundManager.aSoundCategories[_loc2_].sName == __sCategoryName)
{
Library.Sound.SoundManager.aSoundCategories[_loc2_].bMuted = false;
}
}
Library.Sound.SoundManager.doUpdateAllSoundsVolume();
}
static function setMasterVolume(__nVol)
{
Library.Sound.SoundManager.nMasterVolume = __nVol;
Library.Sound.SoundManager.doUpdateAllSoundsVolume();
}
static function get NewSoundAllowed()
{
return Library.Sound.SoundManager.aSounds.length < Library.Sound.SoundManager.MAX_SOUNDS_PLAYING;
}
static function get MasterVolume()
{
return Library.Sound.SoundManager.nMasterVolume;
}
static function doRemoveListenerFromAllSounds(__oListener)
{
for(var _loc2_ in Library.Sound.SoundManager.aSounds)
{
Library.Sound.SoundManager.aSounds[_loc2_].doRemoveListener(__oListener);
}
}
static function doDestroy()
{
Library.Sound.SoundManager.doRemoveListenerFromAllSounds();
for(var _loc1_ in Library.Sound.SoundManager.aSounds)
{
Library.Sound.SoundManager.aSounds[_loc1_].doDestroy();
}
}
static function doUpdateAllSoundsVolume()
{
for(var _loc1_ in Library.Sound.SoundManager.aSounds)
{
Library.Sound.SoundManager.aSounds[_loc1_].doUpdateSound();
}
}
static function doCheckInit()
{
if(Library.Sound.SoundManager.bInited)
{
}
}
static function doManageCategory(__sCategoryName)
{
Library.Sound.SoundManager.doCheckInit();
var _loc1_ = false;
for(var _loc4_ in Library.Sound.SoundManager.aSoundCategories)
{
if(Library.Sound.SoundManager.aSoundCategories[_loc4_].sName == __sCategoryName)
{
_loc1_ = true;
}
}
if(!_loc1_)
{
var _loc3_ = new Object();
_loc3_.sName = __sCategoryName;
_loc3_.nVolume = 100;
_loc3_.bMuted = false;
Library.Sound.SoundManager.aSoundCategories.push(_loc3_);
}
}
}